<template>
    <div id="descriptions">
        <van-grid :board="false" :column-num="columns">
            <van-grid-item v-for="(item, index) in data" :key="index">
                <div class="title" @click="showDialog(item)">{{ item.title }}</div>
                <div class="value" @click="$emit('sort', item)">
                    <color-text :value="item.value">
                        {{ numberFormat(item.value, item.scale) + item.unity }}
                    </color-text>
                </div>
            </van-grid-item>
        </van-grid>
    </div>
</template>

<script>
import { Dialog } from 'vant'
import { numberFormat } from '@/utils'

export default {
    components: {
        ColorText: () => import('@/components/ColorText.vue')
    },
    props: {
        columns: Number,
        data: Array
    },
  methods: {
    numberFormat: numberFormat,
      showDialog(item) {
        Dialog.alert({
          title: item.title,
          message: item.blurb,
        })
      }
  }
}
</script>

<style scoped>
#descriptions {
    border-left: solid 1px #ebeef5;
    text-align: center;
}

#descriptions /deep/ .van-grid-item__content {
    padding: 0 !important;
}

.title,
.value {
    width: 100%;
    height: 40px;
    line-height: 40px;
}

.title {
    background-color: #fafafa;
}
</style>
